package reportcenter.report.support;

import ar.com.fdvs.dj.core.DJConstants;
import ar.com.fdvs.dj.core.DynamicJasperHelper;
import ar.com.fdvs.dj.core.layout.ClassicLayoutManager;
import ar.com.fdvs.dj.domain.AutoText;
import ar.com.fdvs.dj.domain.DynamicReport;
import ar.com.fdvs.dj.domain.ImageBanner;
import ar.com.fdvs.dj.domain.Style;
import ar.com.fdvs.dj.domain.builders.ColumnBuilder;
import ar.com.fdvs.dj.domain.builders.DynamicReportBuilder;
import ar.com.fdvs.dj.domain.constants.Border;
import ar.com.fdvs.dj.domain.constants.Font;
import ar.com.fdvs.dj.domain.constants.HorizontalAlign;
import ar.com.fdvs.dj.domain.constants.Transparency;
import ar.com.fdvs.dj.domain.constants.VerticalAlign;
import ar.com.fdvs.dj.domain.entities.columns.AbstractColumn;
import java.awt.Color;
import java.sql.Connection;
import java.util.Map;
import net.sf.jasperreports.engine.JasperPrint;
import reportcenter.report.dominio.column.ReportColum;
import reportcenter.report.dominio.report.Report;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import reportcenter.support.dbutil.ConnectionManager;
import reportcenter.support.resourceload.DataSourceConfig;

/**
 *
 * @author renan_luz
 */
public class ReportManager{
    
    
    public static Map QUERY_PARAMS;
    public static String TARGET_FILE_PATH;
    public static String TARGET_FILE_NAME;
    
    public static Report REPORT;
    
//    protected abstract void configure() throws Exception;
    
    public ReportManager(Report report){
        REPORT = report;
    }
    
//    protected abstract JasperPrint getJasperPrint(Report report) throws Exception;
//    {
//        new ConnectionManager(new DataSourceConfig(report.getIdD()));
//        Connection conn = ConnectionManager.ds.getConnection();
//
//        //Definir ESTILO
//        
//        Style headerStyle = new Style();
//        headerStyle.setFont(Font.VERDANA_MEDIUM_BOLD);
//        headerStyle.setBorderBottom(Border.PEN_2_POINT);
//        headerStyle.setHorizontalAlign(HorizontalAlign.CENTER);
//        headerStyle.setVerticalAlign(VerticalAlign.MIDDLE);
//        headerStyle.setBackgroundColor(Color.DARK_GRAY);
//        headerStyle.setTextColor(Color.WHITE);
//        headerStyle.setTransparency(Transparency.OPAQUE);
//        headerStyle.setStretchWithOverflow(Boolean.TRUE);
//        
//        Style detailStyle = new Style();
//        detailStyle.setStretchWithOverflow(Boolean.TRUE);
//        
//
//        Style titleStyle = new Style();
//        titleStyle.setFont(new Font(16, Font._FONT_VERDANA, true));
//        titleStyle.setStretchWithOverflow(Boolean.TRUE);
//        titleStyle.setBackgroundColor(Color.GREEN);
//        
//        Style oddRowStyle = new Style();
//        oddRowStyle.setBorder(Border.NO_BORDER);
//        oddRowStyle.setBackgroundColor(Color.LIGHT_GRAY);
//        oddRowStyle.setTransparency(Transparency.OPAQUE);
//
//        
//
//        DynamicReportBuilder drb = new DynamicReportBuilder();
//        Integer margin = new Integer(10);
//        drb.addSubtitle(report.getSubtitle())
//                .addTitleStyle(titleStyle) //defines the style of the title
//                .addDetailHeight(new Integer(15)) //defines the height for each record of the report
//                .addLeftMargin(margin) //define the margin space for each side (top, bottom, right and left)
//                .addRightMargin(margin)
//                .addTopMargin(margin)
//                .addBottomMargin(margin)
//                .addColumnsPerPage(new Integer(1)).setPrintBackgroundOnOddRows(true).setOddRowBackgroundStyle(oddRowStyle)
//                .addFirstPageImageBanner("images/qq_medio.jpg", new Integer(122), new Integer(47), ImageBanner.ALIGN_RIGHT).addImageBanner("images/qq_medio.jpg", new Integer(122), new Integer(47), ImageBanner.ALIGN_RIGHT);
//
//        for (ReportColum f : report.getReportColumCollection()) {
//            AbstractColumn column = ColumnBuilder.getInstance() //creates a new instance of a ColumnBuilder
//                    .addColumnProperty(f.getColumnName(), f.getClazz()) //defines the field of the data source that this column will show, also its type
//                    .addTitle(f.getColumnDescr()) //the title for the column
//                    .addWidth(f.getWidth()) //the width of the column
//                    .addStyle(detailStyle) //defines the style for the records of this column
//                    .addHeaderStyle(headerStyle) //defines the style for the title of this column
//                    .build();
//
//            drb.addColumn(column);
//
//        }
//
//        drb.setUseFullPageWidth(true);
////        drb.addAutoText(AutoText.AUTOTEXT_PAGE_X_OF_Y, AutoText.POSITION_FOOTER, AutoText.ALIGMENT_LEFT);
//        drb.setTitle(report.getTitle());
//        drb.setQuery(report.getQuery(), DJConstants.QUERY_LANGUAGE_SQL);
//
//        DynamicReport dr = drb.build();
//        JasperPrint jp = DynamicJasperHelper.generateJasperPrint(dr, new ClassicLayoutManager(), conn, QUERY_PARAMS);
//
//        conn.close();
//        return jp;
//    }
}
